FROM ubuntu:22.04

ARG DEBCONF_NOWARNINGS="yes"
ARG DEBIAN_FRONTEND="noninteractive"
ARG DEBCONF_NONINTERACTIVE_SEEN="true"
ARG LANG="en_US.UTF-8"

# install basic utilities
RUN set -eu && \
    sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list && \
    sed -i 's/security.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list && \
    sed -i s@/archive.ubuntu.com@/mirrors.aliyun.com@g /etc/apt/sources.list && \
    sed -i s@/security.ubuntu.com@/mirrors.aliyun.com@g /etc/apt/sources.list && \
    apt-get update && \
    apt-get install -y locales && \
    locale-gen en_US en_US.UTF-8 && \
    update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \
    export LANG=en_US.UTF-8 && \
    apt-get update && \
    apt-get install -y lsb-release build-essential file git curl wget vim net-tools

# install miniforge for isolated python env (RoboStack), so that we can use non-ROS python ecosystem
# without conflicts with ROS python pkgs
RUN wget -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" && \
    bash Miniforge3.sh -b -p "/root/conda" && \
    . "/root/conda/etc/profile.d/conda.sh" && \
    conda init && \
    cd /root && \
    conda config --env --remove channels defaults || true && \
    conda create -n ros_env -c conda-forge -c robostack-humble python=3.12 && \
    conda activate ros_env && \
    conda install -y \
        pip \
        rosdep \
        vcstool \
        colcon-common-extensions \
        catkin_pkg \
        numpy \
        lark \
        setuptools \
        empy==3.3.4


ENV WS_ROOT=/mnt/ohos

COPY entrypoint.sh /entrypoint.sh
COPY build.sh /usr/bin/build-ros-humble
RUN chmod +x /entrypoint.sh && \
    chmod +x /usr/bin/build-ros-humble

ENTRYPOINT ["/entrypoint.sh"]

CMD ["/bin/bash"]

